package com.cloudcentral.feign.fallback;

import com.cloudcentral.entity.dto.SMSCodeDTO;
import com.cloudcentral.feign.ToolkitFeign;
import com.cloudcentral.util.Result;
import org.springframework.cloud.openfeign.FallbackFactory;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RequestPart;
import org.springframework.web.multipart.MultipartFile;

import static com.cloudcentral.util.Utils.errorMessage;

/**
 * Create by Administrator
 * 2023/11/1 11:15
 */
public class ToolkitFeignFallback implements FallbackFactory<ToolkitFeign> {
  @Override
  public ToolkitFeign create(Throwable throwable) {
    return new ToolkitFeign() {
      @Override
      public Result<Boolean> code(SMSCodeDTO dto) {
        return Result.exception(errorMessage(throwable));
      }

      @Override
      public Result<String> uploadPCM(@RequestParam String pcm) {
        return Result.exception(errorMessage(throwable));
      }

      @Override
      public Result<String> uploadCSV(@RequestParam String content) {
        return Result.exception(errorMessage(throwable));
      }

      @Override
      public Result<String> uploadFile(@RequestParam String type, @RequestPart MultipartFile file) {
        return Result.exception(errorMessage(throwable));
      }

      @Override
      public Result<Boolean> delete(String uri) {
        return Result.exception(errorMessage(throwable));
      }
    };
  }
}
